<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增产品信息')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">产品名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="infoName" id="infoName" required>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">产品系列：</label>
				<div class="col-sm-8">
					<select name="seriesId" id="seriesId">
						<option value="0">请选择</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">产品规格：</label>
				<div class="col-sm-8">
					<select name="sizeId" id="sizeId">
						<option value="0">请选择</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">产品风格：</label>
				<div class="col-sm-8">
					<select name="styleId" id="styleId">
						<option value="0">请选择</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">显示顺序：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="infoSort" id="infoSort" required>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">材质：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="material" id="material" required>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "product/info";
	    
		/*$("#form-post-add").validate({
			onkeyup: false,
			rules:{
				infoName:{
					remote: {
		                url: ctx + "product/info/checkInfoNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"infoName" : function() {
		                        return $.common.trim($("#seriesName").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				seriesSort:{
					digits:true
				},
			},
			messages: {
		        "seriesName": {
		            remote: "产品系列已经存在"
		        }
		    },
		    focusCleanup: true
		});*/
		
		function submitHandler() {
			if ($.validate.form()) {
				$.operate.save(prefix + "/add", $('#form-post-add').serialize());
			}
		}
	</script>
	<script>
		$(function () {

			$.post("/product/info/getSeries",function (result) {
				for(var i in result){
					$("#seriesId").append('<option value="'+result[i].seriesId+'">'+result[i].seriesName+'</option>')
				}
			});
			$.post("/product/info/getSize",function (result) {
				for(var i in result){
					$("#sizeId").append('<option value="'+result[i].sizeId+'">'+result[i].sizeName+'</option>')
				}
			});
			$.post("/product/info/getStyle",function (result) {
				for(var i in result){
					$("#styleId").append('<option value="'+result[i].styleId+'">'+result[i].styleName+'</option>')
				}
			});

		})
	</script>
</body>
</html>
